from django.contrib.auth.models import User
from django.db import models

# Create your models here.


# 用户详情展示
class UserDetail(models.Model):
    SEX_CHOICES = (
        (0, '女'),
        (1, '男')
    )
    avatar = models.TextField(null=True, blank=True, verbose_name='头像')
    phone = models.CharField(max_length=11, unique=True, null=True, blank=True, verbose_name='电话')
    age = models.SmallIntegerField(null=True, blank=True, verbose_name='年龄')
    sex = models.SmallIntegerField(null=True, blank=True, verbose_name='性别', choices=SEX_CHOICES)
    birthday = models.DateField(null=True, blank=True, verbose_name='生日')

    user = models.OneToOneField(User, on_delete=models.CASCADE)  # cascade同步删除

    class Meta:
        db_table = 'detail'  # 表名
        verbose_name = '用户详情'  # 中文表名
        verbose_name_plural = verbose_name  # 中文表名复数